﻿@{
    ViewBag.Title = "资料收集";
    var id = Model != null ? Model.ID : 0;
}
@using ZBJF.Warranty.Common.Enums.InsuranceWarranty
@using ZBJF.Warranty.WebProvider
@model ZBJF.Warranty.Model.InsuranceWarrantyRecord

@Html.AntiForgeryToken()
@Html.HiddenFor(m => m.ID)
@Html.HiddenFor(m => m.WarrantyRecordNo)
@Html.HiddenFor(m => m.CreateTime)
@Html.HiddenFor(m => m.Reporter)
@Html.HiddenFor(m => m.ReporterPhone)

<ul id="myTab" class="nav nav-tabs">
    @{
        var imageList = Model.InsuranceWarrantyRecordImages.ToList();
        var imageTypeList = new List<int>();
        for (int i = 0; i < imageList.Count; i++)
        {
            var image = imageList[i];
            if (!imageTypeList.Contains(image.ImageType))
            {
                <li class="@(i == 0 ? "active" : "")">
                    <a href="#@image.ImageType" data-toggle="tab">
                        @ZBJF.Warranty.Common.Common.EnumHelper.Instance.GetDescription(typeof(WarrantyRecordImageEnums), image.ImageType)
                    </a>
                </li>
            }
            imageTypeList.Add(image.ImageType);
        }
    }
</ul>

<div id="myTabContent" class="tab-content">
    @{
        imageTypeList = new List<int>();
        for (int i = 0; i < imageList.Count; i++)
        {
            var image = imageList[i];
            if (!imageTypeList.Contains(image.ImageType))
            {
                <div class="tab-pane padding-10 fade in @(i == 0 ? "active" : "")" id="@image.ImageType">
                    <table id="tb_@image.ImageType" class="table table-bordered">
                        <thead>
                            <tr>
                                <th>
                                    图片类别
                                </th>
                                <th>大小</th>
                                <th>上传人</th>
                                <th>上传时间</th>
                                <th>点击查看</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>@ZBJF.Warranty.Common.Common.EnumHelper.Instance.GetDescription(typeof(WarrantyRecordImageEnums), image.ImageType)</td>
                                <td>@(int.Parse(image.FileSize) / 1024 + "KB")</td>
                                <td>@image.CreateBy</td>
                                <td>@image.CreateTime</td>
                                <td><a target="_blank" href="@image.FilePath">@image.FileName</a></td>
                              
                            </tr>
                        </tbody>
                    </table>
                </div>
            }
            else
            {
                <script>
                    $(function () {
                        var html = "<tr><td>@ZBJF.Warranty.Common.Common.EnumHelper.Instance.GetDescription(typeof(WarrantyRecordImageEnums), image.ImageType)</td><td>@(int.Parse(image.FileSize) / 1024 + "KB")</td><td>@image.CreateBy</td><td>@image.CreateTime</td><td><a target='_blank' href='@image.FilePath''>@image.FileName</a></td></tr>";
                        $("#tb_@image.ImageType tbody").append(html);
                    });
                </script>
            }
            imageTypeList.Add(image.ImageType);
        }
    }
</div>

